package com.github.wxiaoqi.security.crm.core.api;

import java.util.Map;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.wxiaoqi.security.common.crm.request.LoginRequest;
import com.github.wxiaoqi.security.common.crm.request.RegisterRequestParam;
import com.github.wxiaoqi.security.crm.core.biz.CustomerBaseBiz;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags="个人客户基础信息管理")
@Controller
@RequestMapping("personalBase")
public class CustomerController {

	@Autowired
	private CustomerBaseBiz customerBaseBiz;
	/**
	 * 用户注册
	 * @author centerroot
	 * @time 创建时间:2018年9月7日下午5:00:32
	 * @param personalBaseRequest
	 * @return
	 */
	@ApiOperation("用户注册")
	@RequestMapping(value = "/register",method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> register(@RequestBody @Valid RegisterRequestParam registerRequest) {
        Map<String, Object> response = customerBaseBiz.register(registerRequest);
		return response;
    }
	
	/**
	 * 用户登录
	 * @author centerroot
	 * @time 创建时间:2018年9月7日下午5:00:32
	 * @param loginRequest
	 * @return
	 */
	@ApiOperation("用户登录")
	@RequestMapping(value = "/login",method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> login(@RequestBody @Valid LoginRequest loginRequest) {
        Map<String, Object> response = customerBaseBiz.login(loginRequest);
		return response;
    }

}
